package com.cjjd.c.feature.dialog;

import android.app.Dialog;
import android.content.Context;
import android.text.InputType;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.cjjd.c.R;

/**
 * ----------------------------------
 * Created by xyd on 2017/10/12.
 * <p/>
 * 描  述：
 * <p/>
 * 修订历史:
 * ----------------------------------
 */

public class ChangeNameDialog extends Dialog implements View.OnClickListener {

    private Context mContext;
    private String tittle;
    private String inputHint;
    private OnClickListener listener;

    private TextView tvTitle;
    private EditText etContent;

    public ChangeNameDialog(Context context, String tittle, String inputHint, OnClickListener listener) {
        super(context, R.style.loading_dialog);

        setContentView(R.layout.dialog_reward);

        this.mContext = context;
        this.tittle = tittle;
        this.inputHint = inputHint;
        this.listener = listener;
        initView();
    }

    private void initView() {
        tvTitle = (TextView) findViewById(R.id.tv_title);
        etContent = (EditText) findViewById(R.id.et_money);
        findViewById(R.id.btn_reward).setOnClickListener(this);
        findViewById(R.id.close).setOnClickListener(this);

        tvTitle.setText(tittle);
        etContent.setInputType(InputType.TYPE_CLASS_TEXT);
        etContent.setHint(inputHint);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btn_reward:
                listener.onClick(etContent.getText().toString().trim());
                if (TextUtils.isEmpty(etContent.getText().toString().trim())) {
                    return;
                }
                this.dismiss();
                break;
            case R.id.close:
                this.dismiss();
                break;
        }
    }

    public interface OnClickListener {

        public void onClick(String inputString);

    }
}
